Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

simple face centered cubic 3D lattice figures

Project: A Project
Path: QMSE02-2018-01-16/fcc.ipynb / cdoc="<!DOCTYPE html><html><head><title>< / title><meta charset=&quot;utf-8&quot;><meta name=viewport content=&quot;width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0&quot;><style> body { margin: 0px; overflow: hidden; } < / style>< / head><body><script src=&quot;https: / cdn.rawgit.com / mrdoob / three.js / r80 / build / three.min.js&quot;>< / script><script src=&quot;https: / cdn.rawgit.com / mrdoob / three.js / r80 / examples / js / controls / OrbitControls.js&quot;>< / script> <script> var scene = new THREE.Scene(); var renderer = new THREE.WebGLRenderer( { antialias: true } ); renderer.setSize( window.innerWidth, window.innerHeight ); renderer.setClearColor( 0xffffff, 1 ); document.body.appendChild( renderer.domElement ); var options = {&quot;aspect_ratio&quot;: [1.0, 1.0, 1.0], &quot;decimals&quot;: 2, &quot;frame&quot;: true, &quot;axes&quot;: false, &quot;axes_labels&quot;: [&quot;x&quot;, &quot;y&quot;, &quot;z&quot;]}; / When animations are supported by the viewer, the value 'false' / will be replaced with an option set in Python by the user var animate = false; / options.animate; var b = [{&quot;x&quot;:-3.42893218813, &quot;y&quot;:-3.42893218813, &quot;z&quot;:-3.42893218813}, {&quot;x&quot;:10.6, &quot;y&quot;:10.6, &quot;z&quot;:10.6}]; / bounds if ( b[0].x === b[1].x ) { b[0].x -= 1; b[1].x += 1; } if ( b[0].y === b[1].y ) { b[0].y -= 1; b[1].y += 1; } if ( b[0].z === b[1].z ) { b[0].z -= 1; b[1].z += 1; } var rRange = Math.sqrt( Math.pow( b[1].x - b[0].x, 2 ) + Math.pow( b[1].x - b[0].x, 2 ) ); var xRange = b[1].x - b[0].x; var yRange = b[1].y - b[0].y; var zRange = b[1].z - b[0].z; var ar = options.aspect_ratio; var a = [ ar[0], ar[1], ar[2] ]; / aspect multipliers var autoAspect = 2.5; if ( zRange > autoAspect * rRange && a[2] === 1 ) a[2] = autoAspect * rRange / zRange; var xMid = ( b[0].x + b[1].x ) / 2; var yMid = ( b[0].y + b[1].y ) / 2; var zMid = ( b[0].z + b[1].z ) / 2; var box = new THREE.Geometry(); box.vertices.push( new THREE.Vector3( a[0]*b[0].x, a[1]*b[0].y, a[2]*b[0].z ) ); box.vertices.push( new THREE.Vector3( a[0]*b[1].x, a[1]*b[1].y, a[2]*b[1].z ) ); var boxMesh = new THREE.LineSegments( box ); if ( options.frame ) scene.add( new THREE.BoxHelper( boxMesh, 'black' ) ); if ( options.axes_labels ) { var d = options.decimals; / decimals var offsetRatio = 0.1; var al = options.axes_labels; var offset = offsetRatio * a[1]*( b[1].y - b[0].y ); var xm = xMid.toFixed(d); if ( / ^-0.
Views: 245